INTRODUCTION
This is a little something I cooked up when I had some spare time (god, I can't remember
the last time that was ~_-) to test the loadplugin function in Avisynth 1.0.  This project
has been on the shelf for some time now since I don't have any time to work on it right
now.  However, I share this "partial" work with you because the InverseTelecine part of
it is fully functionnal and I've been using it for some time with great results.  The
other part of it (DeInterlacing) is still in the construction phase, but I have high hopes
of finishing it sometime (I don't know when).

WHATS NEW
2.1
Added a new function (suggested by canman), Decimate.  Also, I worked on DeInterlace to
make it more relyable since I am using it more often now :).  Corrected a few bugs in
the IVTC part (thanks to those who reviewed my code) which will prevent hangs and erorr
messages that were apearing in certain cases.

2.0
I changed a few thing within the code to make thing easier for you guys... First, no more
doubleweaving, the plug-in does that on it's own (any volonteers for uptimizing this??).
Second, it also detects reversed field order so you don't have to guess if it is or not.
Third, I added a DeInterlace function that only matches fields (no blending) and doesn't
change the framerate (useful for hybrid material).

PLANS
Still working on building 60 fps streams with duplicate frames that don't get encoded (or
don't take that much space).  May add support for RGB in InverseTelecine if enough ppl use
it.  ;)

WHAT YOU NEED TO KNOW
This plug-in was designed to work with avisynth 1.0 or higher.  I don't know if it could
work with any other program (I'm pretty sure it couldn't) and I wouldn't recommend
trying.

  InverseTelecine
	InverseTelecine reconstruct progressive 24 fps streams out of NTSC 29.97 telecined
	streams.

	1- To work properly, the plug-in requires that the video stream be in a YUV format
	   (more on this farther down the document).  In fact, anything else will probably 
	   get seriouly screwed!

	2- It is supposed to reconstruct video streams which have gone through Telecine 
	   process.  The plug-in can't InverseTelecine video streams which are only Interlaced 
	   or haven't gone through a recognised Telecine process.

	3- The plug-in takes in 3 parameters: High limit, Low limit and Threshold(more
	   on this farther down the document).  Values can range from 0 to 255 for High and 
	   Low limit, and 1 or more for threshold (I've had good results with values of 40,10,15).

		ex:  LoadPlugIn("c:\archive\InverseTelecine.dll")
		     SegmentedAviSource("D:\capture.avi")
		     InverseTelecine(40,10,15)

  DeInterlace
	DeInterlace takes an interlaced stream and reconstruct a progressive stream by
	matching field pairs (no blending).

	1- Right now it doesn't require any parameter, but that may change...

		ex:  LoadPlugIn("c:\archive\InverseTelecine.dll")
		     SegmentedAviSource("D:\capture.avi")
		     DeInterlace

	2- To work properly, DeInterlace needs to be able to find the correct match of fields
	   in the current frame or the adjacent frames. What this means is that if streams
	   are stiched together or your capture card doesn't work very well, you may see
	   some interlaced frames get through.
	   
  Decimate
	Decimate removes 1 duplicate field out of each group of frame specified.  In effect
	it does the same type of thing as InverseTelecine, but on non-interlaced streams.

	1- This one takes 3 parameters: Group, Filter and Threshold.
	   Group:  Specifies the number of frames in a group from which 1 frame must be 
		   removed.  Ex:  Group = 5 means that 1 frame is removed in each group of
				  5 (this is the equivalent of IVTC)

	   Filter: Lets the plug-in know how close the luma values of 2 pixels must be to
		   be considered the same.  For DVDs, I recommend setting this between 4 to
		   8 (I used 8 for my tests) and 16 or less for VHS.

	   Threshold: Indicates how similar 2 frames must be to be considered as such. For
		   the moment, the values for this parameter should be set between 100 to
		   1000 (I used 500 for my tests) with high values for streams of lesser
		   quality or greater amount of movement.

ADVANCED INFORMATION
  YUV and RGB formats
  As far as I know, any codec will decompress in either a YUV or RGB format.  To keep it
  simple, RGB defines a pixel by assigning 8 bits for RED, GREEN and BLUE values.  YUV
  defines a pixel by its Luminence and 2 Chroma (which is the difference between 2 colors
  and I can't remember which).  The thing to remember here is that the plug-in uses the Luma
  value to see if 2 lines are interlaced, so RGB format will not return the correct
  information.  If your codec does not decompress as YUV, try using the CONVERTTOYUY2
  function.

  Telecine process
  A process by which a video stream of 24 fps is converted to a stream or 29.97 fps (NTSC
  standard) by adding 2 fields (either odd lines or even lines) every 5 frames (not at the
  same time).  By doing so, 3 out of 5 frames become interlaced, which will dislpay fine
  on an interlaced screen but display badly on computer screens.

  InverseTelecine Parameters
    High Limit: If the difference between the luma values of 2 pixels (one above another) are
  	        higher than this, the pixel are considered "interlaced".

    Low Limit:  If the difference between the luma values of 2 pixels (one above another) are
 	        lower than this, the pixel are considered "not interlaced".

    Threshold:  The interlace value at which a recalculation of the pulldown order is
                necessary.

  How the InverseTeplug-in works
  First, the plug-in analyses the first 5 frames and determines the pulldown order by 
  selecting the 2 frames with the less interlace artifacts.  Then, it continues to select
  each next frame by using the previously determined pulldown order.  However, each output
  frame is analysed to ensure that no interlaced frame gets by.  If the interlace value of
  an output frame exceeds the threshold value, the pulldown order is recalculated.

CONTACTS
Email: Wizard_FL@Hotmail.com
ICQL: 4105331
  